import BinaryLineTreeNode from "./BinaryLineTreeNode";
import _ from 'lodash';
import { isPt } from "../../../math/Point3d";
export default class BinaryLineTree {
  constructor() {
    this.root = new BinaryLineTreeNode(null);
  }

  insert(value) {
    const cloneVal = _.cloneDeep(value);
    return this.root.insert(cloneVal);
  }

  findPath(pt) {
    if (!isPt(pt)) return;
    return this.root.findPath(pt);
  }
  findPathId(pt){
    if (!isPt(pt)) return;
    const path = this.findPath(pt);
    return path.map(item=> item.vid);
  }

  toString() {
    return this.root.toString();
  }
}